{include file='public/header' /}
<div class="layuimini-container" >
    <form id="modelUserForm" lay-filter="modelUserForm" class="layui-form model-form">
        <input name="id" type="hidden"/>

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend><b>订单信息</b></legend>
        </fieldset>

        <div style="padding: 20px; background-color: #F2F2F2;">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header"><b>退款</b></div>
                        <div class="layui-card-body">
                            {$row.OrderList.real_price} （元）
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header"><b>用户昵称</b></div>
                        <div class="layui-card-body">
                            {$row.User.nick_name}
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header"><b>支付类型</b></div>
                        <div class="layui-card-body">
                            {if condition="$row->Order->pay_type eq 1"}
                            微信支付
                            {elseif condition="$row->pay_type eq 2"}
                            积分兑换
                            {elseif condition="$row->pay_type eq 3"}
                            支付宝支付
                            {else/}
                            暂无
                            {/if}

                        </div>
                    </div>
                </div>

                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header"><b>售后时间</b></div>
                        <div class="layui-card-body">
                            {$row->create_time}
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header"><b>退款原因</b></div>
                        <div class="layui-card-body">
                            {$row->comment}
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header"><b>退款备注</b></div>
                        <div class="layui-card-body">
                            {$row->desc}
                        </div>
                    </div>
                </div>
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header"><b>退款图片</b></div>

                        {foreach $row->refund_images as $im }
                        <div class="layui-card-body ">
                            <img src="{$im}" class="layui-upload-img" width="60">
                        </div>
                        {/foreach}
                        <hr class="layui-bg-orange">
                    </div>
                </div>
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                    <legend><b>商品信息</b></legend>
                </fieldset>

                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header"><b>商品标题</b> ：{$row->Goods->title}</div>
                        <div class="layui-card-body">
                            <img src="{$row->GoodsSku->sku_image}" class="layui-upload-img" width="60">
                        </div>
                        <div class="layui-card-header"><b>原价</b> ：{$row->GoodsSku->goods_price}</div>
                        <div class="layui-card-header"><b>实际支付价</b> ：{$row->OrderList->real_price}</div>
                        <div class="layui-card-header"><b>规格</b> ：{$row->GoodsSku->spec_sku_name}</div>
                        <div class="layui-card-header"><b>数量</b> ：{$row->OrderList->number}</div>
                        <hr class="layui-bg-orange">
                    </div>
                </div>

                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header"><b>售后操作</b></div>
                        <div class="layui-card-body">
                            {if condition="$row->type eq 1 and $row->status eq 0"}
                            <button type="button" id="to_mes" class="layui-btn layui-btn-normal">审核</button>
                            {/if}

                        </div>
                    </div>
                </div>

                {if condition="$row.type == 2 and $row.status ==4"}
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header"><b>发货信息</b></div>
                        <div class="layui-card-body">
                            <div class="layui-card-header"><b>快递公司</b> ：{$row->mes}</div>
                            <div class="layui-card-header"><b>快递单号</b> ：{$row->mes_no}</div>
                        </div>
                    </div>
                </div>
                {/if}

            </div>
        </div>


        {if condition="$row->status eq 0"}

        {/if}
        <!--<div class="layui-form-item text-center" style="position: fixed; bottom: -30px;width:100%;height:80px">
            <input type="hidden" name="id" value="{$row.id}">
            <button class="layui-btn layui-btn-primary" type="button" onclick="close_window()" >关闭</button>
          &lt;!&ndash;  <button class="layui-btn" lay-filter="modelSubmitUser" lay-submit>保存</button>&ndash;&gt;
        </div>-->

    </form>
</div>

<!-- 表单弹窗 -->
<script type="text/html" id="modelRole">
    <form id="modelRoleForm" lay-filter="modelRoleForm" class="layui-form model-form">
        <input name="id" type="hidden" value="{$row->id}"/>

        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">审核操作</label>
            <div class="layui-input-block">
                {if condition="$row->status == 0 and $row->type ==1"}
                <input type="radio" lay-filter="raQT" name="status" value="1" checked title="同意" >
                {else if condition="$row->status == 4 and $row->type ==2"}
                <input type="radio" lay-filter="raQT" name="status" value="1" checked title="同意" >
                {/if}
                <input type="radio" lay-filter="raQT" name="status" value="2" title="驳回" >
                {if condition="$row->status == 0 and $row->type ==2"}

                <input type="radio" lay-filter="raQT" name="status" value="3" title="同意退货" >
                {/if}
            </div>
        </div>
        <div class="layui-form-item" id="comment" style="display: none">
            <label class="layui-form-label layui-form-required">驳回原因</label>

                <div class="layui-input-block">
                <textarea style="resize: none" name="refund_comment" placeholder="请输入驳回原因" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item" id="address" style="display: none">
            <label class="layui-form-label layui-form-required">退货地址</label>
            <div class="layui-input-block">
                <textarea style="resize: none" name="address" placeholder="请输入退货地址 例如:
浙江省杭州市滨江区阿里巴巴园区
马云
18855412457
 " class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-group text-center" style="margin-top: 50px">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closePageDialog">取消</button>
            <button class="layui-btn" lay-filter="modelSubmitRole" lay-submit>提交</button>
        </div>
    </form>
</script>
{include file='public/footer' /}
<script>

    layui.use(['layer', 'form', 'table', 'util', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;

        $(function(){
            var img_show = null; // tips提示
            $('img').hover(function(){
                var kd=$(this).width();
                kd1=kd*4;          //图片放大倍数
                kd2=kd*4+30;       //图片放大倍数
                var img = "<img class='img_msg' src='"+$(this).attr('src')+"' style='width:"+kd1+"px;' />";
                img_show = layer.tips(img, this,{
                    tips:[2, 'rgba(41,41,41,.5)']
                    ,area: [kd2+'px']
                });
            },function(){
                layer.close(img_show);
            });
        })

        // 表单提交事件
        form.on('submit(modelSubmitUser)', function (data) {
            layer.load(2);
            console.log(data);
            $.post(url, data.field, function (res) {

                layer.closeAll('loading');
                if (res.code == 1) {
                    layer.msg(res.msg, {icon: 1,time: 1000},function(index){
                        window.parent.location.reload();
                    });
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }, 'json');
            return false;
        });

        // 试题类型切换事件
        form.on('radio(raQT)', function (data) {
            changeQT(data.value);
        });

        function changeQT(value, sel) {
            if (value == 2) {
                $('#comment').show();
                $('#address').hide();
            } else if (value == 3) {

                $('#comment').hide();
                $('#address').show();
            }else{
                $('#comment').hide();
                $('#address').hide();
            }
        }
        //发货按钮
        $('#to_mes').click(function(){
            showEditModel()
        })

        // 显示编辑弹窗
        function showEditModel(mRole) {
            admin.open({
                type: 1,
                area:['500px','400px'],
                title: '发货',
                content: $('#modelRole').html(),
                success: function (layero, dIndex) {
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    var url = '{:__url("mall.item_order/edit_refund")}';
                    form.val('modelRoleForm', mRole);  // 回显数据
                    // 表单提交事件
                    form.on('submit(modelSubmitRole)', function (data) {
                        layer.load(2);
                        $.post(url, data.field, function (res) {
                            //layer.closeAll('loading');
                            if (res.code == 1) {
                                layer.close(dIndex);
                                window.location.reload(true);
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'json');
                        return false;
                    });
                }
            });
        }
    });



</script>